'''
        4 = len(s) - 3
A B C D A B C
        ^i
[0:3]
[1:4]
[2:5]
[3:6]
[4:7]

AB BC   AB BC
[]

    ABC
[ABC, BCD, CDA, DAB, ]

ABCD BCDA DABC
[ABCD, BCDA, DABC]

s = "ABCDABC"
for i in range(0, len(s) - 3 + 1)
    print(s[i:i + 2], end = ' ')
'''
def consecutive_substr(path: str, length: int):
    for i in range(0, len(path) - length + 1):
        print(path[i : i + length], end = " ")

# 在 path 里，找长度为 length 的子字符串
# 有重复的，返回 True，否则返回 False
def is_duplicate(path: str, length: int) -> bool:
    result = []

    for i in range(0, len(path) - length + 1):
        sub_str = path[i : i + length]
        
        if sub_str in result:
            return True
        else:
            result.append(sub_str)
    
    return False

path = "ABCDABC"
print(is_duplicate(path = path, length = 4))
